//
// Created by wujehy on 2020/9/13.
//

#include <base_types.h>
#include "TestClientMod.h"
#include "NetworkProtocol.h"
#include "Common.h"
#include <glog/logging.h>
#include <iostream>
//static int64_t getTimeMicro()
//{
//    std::chrono::time_point<std::chrono::system_clock> p = std::chrono::system_clock::now();
//    return std::chrono::duration_cast<std::chrono::microseconds>(p.time_since_epoch()).count();
//}

using namespace GeeJoan;
int64_t lastTime = 0;

int64_t getLastTime()
{
    return lastTime;
}

ModTypeEnum GeeJoan::TestClientMod::mod_type()
{
    return ModType_TestMod;
}

void TestClientMod::procMessage(std::unique_ptr<GeeJoan::ResposeDataPackage> hander)
{

    LOGINFO << " TestClientMod::procMessage " << ResposeDataPackageToString(*hander) << std::endl;

    int64_t currentTime = Common::getTimeMicro();

    // TODO 注掉这里的日志会更快
    LOGWARNING << " recv Taskid = " << int(hander->ctaskid);
    if (hander->subtype == OpTestModSubType_Test2)
    {
        lastTime = currentTime;
        std::cout << " recv taskid = " << int(hander->ctaskid) << " time  = " << currentTime << std::endl;
    }
}
